class Solution(object):
    def isMonotonic(self, nums):
        """
        :type nums: List[int]
        :rtype: bool
        """
        flag = 0
        for i in range(1, len(nums)):
            if nums[i] > nums[i - 1]:
                if not flag:
                    flag = 1
                else:
                    if flag == -1:
                        return False
            if nums[i] < nums[i - 1]:
                if not flag:
                    flag = -1
                else:
                    if flag == 1:
                        return False
        return True